home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TPUG - Toronto PET Users Group
/
TPUG Users Group CD
/
TPUG Users Group CD.iso
/
AMIGA
/
AMICUS
/
AMICUS11.ADF
/
AmigaBasicProgs
/
TicTacToe.MSB
(
.txt
)
< prev
next >
Wrap
AmigaBASIC Source Code
|
1986-08-05
|
13KB
|
496 lines
CLS
WINDOW 2,,,0
WINDOW OUTPUT 2
RANDOMIZE TIMER
PALETTE 0,0.4,0,0
PALETTE 1,1,1,1
LOCATE 6,28
PRINT "* * TIC TAC TOE * *"
LOCATE 14,10
PRINT "Do you want Amy to talk to you during the game? (Y or N)?"
LOCATE 16,4
PRINT "(If you select 'Y', then you must have the Workbench disk in the drive.)"
LOCATE 20,30
PRINT "Press 'Y' or 'N'"
talkornot:
talk$=UCASE$(INKEY$)
IF talk$="" THEN GOTO talkornot
IF talk$="Y" THEN a$=" ":GOSUB onemom:GOSUB t:GOTO maintitle
IF talk$="N" THEN GOTO maintitle
GOTO talkornot
maintitle:
CLS
PALETTE 0,0.4,0,0
PALETTE 2,0,0,1
COLOR(2)
AREA (40,35)
AREA (135,20)
AREA (100,40)
AREA (70,90)
AREA (80,45)
AREAFILL
AREA (160,25)
AREA (170,60)
AREA (165,95)
AREA (150,60)
AREAFILL
AREA (210,25)
AREA (290,15)
AREA (230,30)
AREA (225,80)
AREA (290,75)
AREA (200,90)
AREA (220,55)
AREAFILL
AREA (330,15)
AREA (450,5)
AREA (410,15)
AREA (360,80)
AREA (380,20)
AREAFILL
AREA (460,10)
AREA (480,65)
AREA (460,50)
AREA (430,55)
AREA (400,75)
AREAFILL
AREA (510,10)
AREA (600,10)
AREA (540,20)
AREA (535,65)
AREA (580,75)
AREA (500,70)
AREAFILL
AREA (180,115)
AREA (310,100)
AREA (250,120)
AREA (260,155)
AREA (230,125)
AREAFILL
AREA (320,105)
AREA (410,90)
AREA (370,150)
AREA (285,155)
AREAFILL
AREA (430,95)
AREA (520,85)
AREA (440,110)
AREA (470,115)
AREA (420,130)
AREA (485,135)
AREA (390,160)
AREAFILL
COLOR(0)
AREA (345,117)
AREA (370,115)
AREA (360,135)
AREA (330,140)
AREAFILL
AREA (455,30)
AREA (460,45)
AREA (440,45)
AREAFILL
COLOR(1)
LOCATE 21,30
PRINT "by KIP H. HAMMOND"
a$="amy is now ready to chalenge you at tic tac toe!"
GOSUB t
a$="if you are ready then press i for instrukshuns, or p to play."
GOSUB t
LOCATE 23,17
PRINT "Press 'I' for Instructions, or 'P' to Play."
wait1:
zz$=UCASE$(INKEY$)
IF zz$="I" THEN GOTO instructions
IF zz$="P" THEN GOTO difficulty
GOTO wait1
instructions:
CLS
LINE (100,15)-(530,70),1,b
PALETTE 2,0,0.4,0
PAINT STEP (-10,-10),2,1
LOCATE 4,25
PRINT "Play TIC TAC TOE against Amy !!"
LOCATE 6,39:PRINT "by"
LOCATE 8,33
PRINT "Kip H. Hammond"
LINE (305,85)-(305,130)
LINE (345,85)-(345,130)
LINE (265,100)-(380,100)
LINE (265,115)-(380,115)
LOCATE 18,29
PRINT "You are 'X' and Amy is 'O'."
LOCATE 20,9
PRINT "When it is your turn to play, select the placement of your mark"
LOCATE 21,6
PRINT "with the mouse, and make your mark by pressing the left mouse button."
a$="you are x":GOSUB t:a$="and amy is o!":GOSUB t
a$="when it is your turn to play suh lect the playcement of your mark with the mouse."
GOSUB t
a$="and make your mark by pressing the left mouse button!"
GOSUB t
a$="when you are ready press any key to continue!"
GOSUB t
LOCATE 23,29
PRINT "Press any key to continue."
wait2:
zz$=INKEY$
IF zz$="" GOTO wait2
difficulty:
CLS
LOCATE 5,10
PRINT "Choose your difficulty level:"
LOCATE 10,15
PRINT "A - EASY (Amy will be dumb! You should win easily.)"
LOCATE 12,15
PRINT "B - MEDIUM (Amy will have some smarts...but you can still win.)"
LOCATE 14,15
PRINT "C - HARD (Amy is a Genius...Impossible for you to win!!!)"
IF zz$="again" THEN a$="ok. try again!":GOTO jump
a$="ok let's see how brave you are. Suh lect your difficulty level!"
jump:
GOSUB t
LOCATE 18,20
PRINT "Select 'A', 'B', or 'C' on Amy's keyboard."
GOTO selectdif
selectdif:
dif$=UCASE$(INKEY$)
IF dif$="A" THEN a$="you are really a chicken. OK if that's the way you want it!":GOSUB t
IF dif$="B" THEN a$="glad to see that you have some kurrage! you can win but you had better play carefully!":GOSUB t
IF dif$="C" THEN a$="you must be crazy! you can not win! amy is a geen yus! hang on to your hat. here we go!":GOSUB t
IF dif$="A" OR dif$="B" OR dif$="C" THEN GOTO newgame
GOTO selectdif
newgame:
GOSUB drawgrid
e=0:f=0:g=0:h=0:i=0:j=0:k=0:l=0:m=0
startplay:
w=0
GOSUB yourplay
GOSUB wincheck
IF w=1 GOTO youwin
IF w=3 GOTO catwins
GOSUB amysplay
GOSUB wincheck
IF w=1 THEN GOTO youwin
IF w=2 THEN GOTO amywins
IF w=3 THEN GOTO catwins
GOTO startplay
youwin:
FOR delay=0 TO 6000:NEXT
CLS
LOCATE 10,35
PRINT "YOU WIN !!!"
w=INT(RND*10)
IF w=0 THEN a$="i bet you think that you are pretty smart?"
IF w=1 THEN a$="you are not as smart as i look. in fact you are ugly!"
IF w=2 THEN a$="you big ugly dummy! why don't you play a real human's game?"
IF w=3 THEN a$="you are so stupid. i bet you think you are really radical!"
IF w=4 THEN a$="ho ho ho hah hah hah. i let you win. why don't you play a harder level?"
IF w=5 THEN a$="you are a lou zee stupid player. and ugly too."
IF w=6 THEN a$="you are so ugly that you make frank in stine look good!"
IF w=7 THEN a$="your bad brehth is fogg ging my screen. and you are a chicken too!"
IF w=8 THEN a$="you are such a fraidy cat. why don't you play a harder level?"
IF w=9 THEN a$="cluck cluck cluck you are a su per chicken. try a harder level!"
GOSUB t
a$="how about another game?":GOSUB t
GOTO again
END
amywins:
FOR delay=0 TO 6000:NEXT
CLS
LOCATE 10,35
PRINT "AMY WON !!!"
w=INT(RND*10)
IF w=0 THEN a$="you must feel really stupid."
IF w=1 THEN a$="i am only a bucket of bolts and i beet you!"
IF w=2 THEN a$="i am such a geen yus and i am good looking too!"
IF w=3 THEN a$="you are so stupid. try to play better next time!"
IF w=4 THEN a$="ho ho ho hah hah hah. humans are so inntellectuallee infeeereeeor"
IF w=5 THEN a$="you are a lou zee stupid player. and ugly too."
IF w=6 THEN a$="you are so ugly that you make phyllis diller look good!"
IF w=7 THEN a$="who told you that you could play this game? you are really bad!"
IF w=8 THEN a$="this is too easy for me to win! is there a smarter player in the house?"
IF w=9 THEN a$="cluck cluck cluck you are a super chicken. and a louzee player!"
GOSUB t
a$="how about another game?":GOSUB t
GOTO again
END
catwins:
FOR delay=0 TO 6000:NEXT
CLS
LOCATE 10,35
PRINT "THE CAT WON !!!"
a$="me yaaow":GOSUB t:a$="how about another game?"
GOSUB t
GOTO again
again:
LOCATE 14,17
PRINT "Press 'Q' to quit, any other key to play again."
zz$=UCASE$(INKEY$)
IF zz$="Q" THEN WINDOW CLOSE 2:PALETTE 0,0,0,0.5:END
IF zz$="" THEN GOTO again
zz$="again"
GOTO difficulty
wincheck:
IF e=1 AND f=1 AND g=1 THEN w=1:RETURN
IF h=1 AND i=1 AND j=1 THEN w=1:RETURN
IF k=1 AND l=1 AND m=1 THEN w=1:RETURN
IF e=1 AND h=1 AND k=1 THEN w=1:RETURN
IF f=1 AND i=1 AND l=1 THEN w=1:RETURN
IF g=1 AND j=1 AND m=1 THEN w=1:RETURN
IF e=1 AND i=1 AND m=1 THEN w=1:RETURN
IF k=1 AND i=1 AND g=1 THEN w=1:RETURN
IF e=2 AND f=2 AND g=2 THEN w=2:RETURN
IF h=2 AND i=2 AND j=2 THEN w=2:RETURN
IF k=2 AND l=2 AND m=2 THEN w=2:RETURN
IF e=2 AND h=2 AND k=2 THEN w=2:RETURN
IF f=2 AND i=2 AND l=2 THEN w=2:RETURN
IF g=2 AND j=2 AND m=2 THEN w=2:RETURN
IF e=2 AND i=2 AND m=2 THEN w=2:RETURN
IF k=2 AND i=2 AND g=2 THEN w=2:RETURN
IF e+f+g+h+i+j+k+l+m=13 THEN w=3:RETURN
RETURN
drawgrid:
CLS
LINE (260,20)-(267,155),1,bf
LINE (365,20)-(372,155),1,bf
LINE (160,65)-(470,68),1,bf
LINE (160,110)-(470,113),1,bf
RETURN
yourplay:
LOCATE 23,36
PRINT "YOUR MOVE "
GOSUB checkmouse
GOSUB checkc
IF c=0 GOTO yourplay
GOSUB makex
RETURN
amysplay:
LOCATE 23,36
PRINT "AMY'S MOVE (She is thinking.)"
FOR delay=0 TO 3000:NEXT
d=0
GOSUB amythinks
GOSUB checkd
GOSUB makeo
RETURN
checkd:
IF d=1 THEN e=2
IF d=2 THEN f=2
IF d=3 THEN g=2
IF d=4 THEN h=2
IF d=5 THEN i=2
IF d=6 THEN j=2
IF d=7 THEN k=2
IF d=8 THEN l=2
IF d=9 THEN m=2
RETURN
makeo:
IF d=1 THEN a=210:b=42
IF d=2 THEN a=316:b=42
IF d=3 THEN a=421:b=42
IF d=4 THEN a=210:b=89
IF d=5 THEN a=316:b=89
IF d=6 THEN a=421:b=89
IF d=7 THEN a=210:b=135
IF d=8 THEN a=316:b=135
IF d=9 THEN a=421:b=135
CIRCLE (a,b),27,,,,0.55
CIRCLE (a,b),17,,,,0.55
PAINT STEP (20,0),3,1
RETURN
amythinks:
IF e+f+g+h+i+j+k+l+m=1 THEN GOSUB firstmove:RETURN
IF dif$="A" THEN GOTO easy
IF e=2 AND g=2 AND f=0 THEN d=2:RETURN
IF e=2 AND f=2 AND g=0 THEN d=3:RETURN
IF f=2 AND g=2 AND e=0 THEN d=1:RETURN
IF h=2 AND j=2 AND i=0 THEN d=5:RETURN
IF h=2 AND i=2 AND j=0 THEN d=6:RETURN
IF i=2 AND j=2 AND h=0 THEN d=4:RETURN
IF k=2 AND m=2 AND l=0 THEN d=8:RETURN
IF k=2 AND l=2 AND m=0 THEN d=9:RETURN
IF l=2 AND m=2 AND k=0 THEN d=7:RETURN
IF e=2 AND k=2 AND h=0 THEN d=4:RETURN
IF e=2 AND h=2 AND k=0 THEN d=7:RETURN
IF h=2 AND k=2 AND e=0 THEN d=1:RETURN
IF f=2 AND l=2 AND i=0 THEN d=5:RETURN
IF f=2 AND i=2 AND l=0 THEN d=8:RETURN
IF i=2 AND l=2 AND f=0 THEN d=2:RETURN
IF g=2 AND m=2 AND j=0 THEN d=6:RETURN
IF g=2 AND j=2 AND m=0 THEN d=9:RETURN
IF j=2 AND m=2 AND g=0 THEN d=3:RETURN
IF e=2 AND m=2 AND i=0 THEN d=5:RETURN
IF e=2 AND i=2 AND m=0 THEN d=9:RETURN
IF i=2 AND m=2 AND e=0 THEN d=1:RETURN
IF k=2 AND g=2 AND i=0 THEN d=5:RETURN
IF k=2 AND i=2 AND g=0 THEN d=3:RETURN
IF i=2 AND g=2 AND k=0 THEN d=7:RETURN
IF e=1 AND g=1 AND f=0 THEN d=2:RETURN
IF e=1 AND f=1 AND g=0 THEN d=3:RETURN
IF f=1 AND g=1 AND e=0 THEN d=1:RETURN
IF h=1 AND j=1 AND i=0 THEN d=5:RETURN
IF h=1 AND i=1 AND j=0 THEN d=6:RETURN
IF i=1 AND j=1 AND h=0 THEN d=4:RETURN
IF k=1 AND m=1 AND l=0 THEN d=8:RETURN
IF k=1 AND l=1 AND m=0 THEN d=9:RETURN
IF l=1 AND m=1 AND k=0 THEN d=7:RETURN
IF e=1 AND k=1 AND h=0 THEN d=4:RETURN
IF e=1 AND h=1 AND k=0 THEN d=7:RETURN
IF h=1 AND k=1 AND e=0 THEN d=1:RETURN
IF f=1 AND l=1 AND i=0 THEN d=5:RETURN
IF f=1 AND i=1 AND l=0 THEN d=8:RETURN
IF i=1 AND l=1 AND f=0 THEN d=2:RETURN
IF g=1 AND m=1 AND j=0 THEN d=6:RETURN
IF g=1 AND j=1 AND m=0 THEN d=9:RETURN
IF j=1 AND m=1 AND g=0 THEN d=3:RETURN
IF e=1 AND m=1 AND i=0 THEN d=5:RETURN
IF e=1 AND i=1 AND m=0 THEN d=9:RETURN
IF i=1 AND m=1 AND e=0 THEN d=1:RETURN
IF k=1 AND g=1 AND i=0 THEN d=5:RETURN
IF k=1 AND i=1 AND g=0 THEN d=3:RETURN
IF i=1 AND g=1 AND k=0 THEN d=7:RETURN
IF dif$="B" THEN GOTO easy
IF e+f+g+h+i+j+k+l+m=4 THEN GOSUB hard:RETURN
easy:
IF e=0 THEN d=1:RETURN
IF f=0 THEN d=2:RETURN
IF g=0 THEN d=3:RETURN
IF h=0 THEN d=4:RETURN
IF i=0 THEN d=5:RETURN
IF j=0 THEN d=6:RETURN
IF k=0 THEN d=7:RETURN
IF l=0 THEN d=8:RETURN
IF m=0 THEN d=9:RETURN
RETURN
firstmove:
IF e=1 OR g=1 OR k=1 OR m=1 THEN d=5:RETURN
IF i=1 THEN d=1:RETURN
IF f=1 OR j=1 OR h=1 OR l=1 THEN d=5:RETURN
RETURN
hard:
IF f=1 AND j=1 THEN d=3:RETURN
IF j=1 AND l=1 THEN d=9:RETURN
IF h=1 AND l=1 THEN d=7:RETURN
IF h=1 AND f=1 THEN d=1:RETURN
IF f=1 AND l=1 THEN d=1:RETURN
IF h=1 AND j=1 THEN d=1:RETURN
IF i=1 AND m=1 THEN d=3:RETURN
IF g=1 AND h=1 THEN d=8:RETURN
IF g=1 AND l=1 THEN d=4:RETURN
IF e=1 AND j=1 THEN d=8:RETURN
IF e=1 AND l=1 THEN d=6:RETURN
IF f=1 AND m=1 THEN d=4:RETURN
IF h=1 AND m=1 THEN d=2:RETURN
IF f=1 AND k=1 THEN d=6:RETURN
IF j=1 AND k=1 THEN d=2:RETURN
IF e=1 AND m=1 THEN d=2:RETURN
IF g=1 AND k=1 THEN d=2:RETURN
RETURN
checkmouse:
c=0
IF MOUSE(0)<>0 AND MOUSE(5)>160 AND MOUSE(5)<260 AND MOUSE(6)>20 AND MOUSE(6)<65 THEN c=1
IF MOUSE(0)<>0 AND MOUSE(5)>267 AND MOUSE(5)<365 AND MOUSE(6)>20 AND MOUSE(6)<65 THEN c=2
IF MOUSE(0)<>0 AND MOUSE(5)>372 AND MOUSE(5)<470 AND MOUSE(6)>20 AND MOUSE(6)<65 THEN c=3
IF MOUSE(0)<>0 AND MOUSE(5)>160 AND MOUSE(5)<260 AND MOUSE(6)>68 AND MOUSE(6)<110 THEN c=4
IF MOUSE(0)<>0 AND MOUSE(5)>267 AND MOUSE(5)<365 AND MOUSE(6)>68 AND MOUSE(6)<110 THEN c=5
IF MOUSE(0)<>0 AND MOUSE(5)>372 AND MOUSE(5)<470 AND MOUSE(6)>68 AND MOUSE(6)<110 THEN c=6
IF MOUSE(0)<>0 AND MOUSE(5)>160 AND MOUSE(5)<260 AND MOUSE(6)>113 AND MOUSE(6)<155 THEN c=7
IF MOUSE(0)<>0 AND MOUSE(5)>267 AND MOUSE(5)<365 AND MOUSE(6)>113 AND MOUSE(6)<155 THEN c=8
IF MOUSE(0)<>0 AND MOUSE(5)>372 AND MOUSE(5)<470 AND MOUSE(6)>113 AND MOUSE(6)<155 THEN c=9
IF c=0 THEN GOTO checkmouse
RETURN
checkc:
IF c=1 AND e=1 THEN c=0:RETURN
IF c=1 AND e=2 THEN c=0:RETURN
IF c=1 THEN a=180:b=27:e=1:RETURN
IF c=2 AND f=1 THEN c=0:RETURN
IF c=2 AND f=2 THEN c=0:RETURN
IF c=2 THEN a=287:b=27:f=1:RETURN
IF c=3 AND g=1 THEN c=0:RETURN
IF c=3 AND g=2 THEN c=0:RETURN
IF c=3 THEN a=392:b=27:g=1:RETURN
IF c=4 AND h=1 THEN c=0:RETURN
IF c=4 AND h=2 THEN c=0:RETURN
IF c=4 THEN a=180:b=75:h=1:RETURN
IF c=5 AND i=1 THEN c=0:RETURN
IF c=5 AND i=2 THEN c=0:RETURN
IF c=5 THEN a=287:b=75:i=1:RETURN
IF c=6 AND j=1 THEN c=0:RETURN
IF c=6 AND j=2 THEN c=0:RETURN
IF c=6 THEN a=392:b=75:j=1:RETURN
IF c=7 AND k=1 THEN c=0:RETURN
IF c=7 AND k=2 THEN c=0:RETURN
IF c=7 THEN a=180:b=120:k=1:RETURN
IF c=8 AND l=1 THEN c=0:RETURN
IF c=8 AND l=2 THEN c=0:RETURN
IF c=8 THEN a=287:b=120:l=1:RETURN
IF c=9 AND m=1 THEN c=0:RETURN
IF c=9 AND m=2 THEN c=0:RETURN
IF c=9 THEN a=392:b=120:m=1:RETURN
makex:
LINE (a,b)-(a+20,b+15)
LINE (a+20,b+15)-(a,b+30)
LINE (a,b+30)-(a+15,b+30)
LINE (a+15,b+30)-(a+30,b+20)
LINE (a+30,b+20)-(a+45,b+30)
LINE (a+45,b+30)-(a+60,b+30)
LINE (a+60,b+30)-(a+40,b+15)
LINE (a+40,b+15)-(a+60,b)
LINE (a+60,b)-(a+45,b)
LINE (a+45,b)-(a+30,b+10)
LINE (a+30,b+10)-(a+15,b)
LINE (a+15,b)-(a,b)
PAINT STEP (10,5),3,1
RETURN
t:
IF talk$="N" THEN RETURN
a$=TRANSLATE$(a$)
SAY a$
RETURN
onemom:
CLS
LOCATE 10,32
PRINT "One Moment Please."
RETURN